SRC = handlers64.c handlers64asm.S
INC = -I../../include -I../include -I.
CFLAGS = $(INC)

all: handlers64.bin.o

handlers64.bin.o: $(SRC) depend
	gcc $(CFLAGS) -c handlers64.c handlers64asm.S -mcmodel=large
	objcopy -R.eh_frame -R.comment handlers64.o
	objcopy -R.eh_frame -R.comment handlers64asm.o
	ld -T script.ld --oformat binary -o handlers64.bin handlers64.o handlers64asm.o
	objcopy --input binary --output elf64-x86-64 --binary-architecture i386 handlers64.bin $@

depend: offsets.h

offsets.h: ../include/handlers.h offset_gen.c
	gcc $(CFLAGS) offset_gen.c -o offset_gen
	./offset_gen > $@

clean:
	@rm -rf *.o *.bin offset_gen
